﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Core {
	public class Main : IDisposable {
		protected static Main current;
		public static Main Current { get { if (current == null) current = new Main( ); return current; } }
		public Basic.Config Config;
		public Basic.Accounts Accounts;
		public Basic.Contacts Contacts;
		public Basic.Services Services;
		public Basic.Chats Chats;

		public Plugins.Plugin MyPlugins;
		public Services.Services MyService;

		public Main( ) {
			if (current == null)
				current = this;
			Config = new Basic.Config( );
			Accounts = new Basic.Accounts( );
			Contacts = new Basic.Contacts( );
			Services = new Basic.Services( );
			Chats = new Basic.Chats( );

			MyPlugins = new Plugins.Plugin( );
			MyService = new Services.Services( );
		}

		public void Dispose( ) {
			MyPlugins.Dispose( );
			MyService.Dispose( );
		}

		public void Reload( ) {
			if (System.IO.Directory.Exists(Config.StartupPath + @"\Plugins\")) {
				MyPlugins.LoadPlugins(Config.StartupPath + @"\Plugins\");
				MyService.LoadServices(Config.StartupPath + @"\Plugins\");
			}
		}
	}
}